﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MyDBconnection;

namespace CamposInventory
{
    public partial class frmAddproduct : Form
    {
        DatabaseConnection dbconn = new DatabaseConnection();

       
        public frmAddproduct()
        {
            InitializeComponent();
            btnaddproduct.Click += new EventHandler(btnaddproduct_Click);
            this.Load += new EventHandler(frmInventoryupdate_Load);
            cmbProtype.SelectedIndexChanged += new EventHandler(cmbProtype_SelectedIndexChanged);
            
        }

        void cmbProtype_SelectedIndexChanged(object sender, EventArgs e)
        {
            productdescription();
        }

        void frmInventoryupdate_Load(object sender, EventArgs e)
        {
            
            cmbProtype.Items.Add("Paint");
            cmbProtype.Items.Add("Concrete");
            cmbProtype.Items.Add("Electrical");
            cmbProtype.Items.Add("Plumbing");
            cmbProtype.Items.Add("Houseware");
            cmbProtype.Items.Add("Homehardware");
            cmbunit.Items.Add("Liters");
            cmbunit.Items.Add("Kg");
            cmbunit.Items.Add("Dozen");
            cmbunit.Items.Add("Metre");
            cmbunit.Items.Add("Yard");
            cmbunit.Items.Add("Grams");
           
        }

        void btnaddproduct_Click(object sender, EventArgs e)
        {
            dbconn.dbconnection();
            dbconn.loadproduct("INSERT INTO tblproduct(Productcode,Brand,Category,Description,Saleprice,Supplierprice,Datepurchased)" + "Values('" + txtprocode.Text + "','" + txtProname.Text + "','" + cmbProtype.Text + "','"+cmbProdescrip.Text +"','"+txtsaleprice.Text+"','"+txtsupplierprice.Text+"','" + dateTimePicker1.Text+ "')");
            MessageBox.Show("Product Added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            dbconn.DBClose();
            
        }



        void productdescription()
        {
            switch (cmbProtype.Text)
            {
                case "Paint":
                    cmbProdescrip.Items.Clear();
                    cmbProdescrip.Items.Add("Flat Latex white ");
                    cmbProdescrip.Items.Add("Clear Acrylic emulsion");
                    cmbProdescrip.Items.Add("Clear Dead Flat");
                    cmbProdescrip.Items.Add("Clear Gloss Lacquer");
                    cmbProdescrip.Items.Add("Lacquer Sanding Sealer");        
                    
                    break;
                    

                case "Concrete":
                    cmbProdescrip.Items.Clear();
                    cmbProdescrip.Items.Add("Holcim Excel");
                    cmbProdescrip.Items.Add("Holcim WallRight");
                    break;
                
            
            }


        
        
        
        }

        
    }
}
